<?php
// +----------------------------------------------------------------------
// | HisiPHP框架[基于ThinkPHP5.1开发]
// +----------------------------------------------------------------------
// | Copyright (c) 2016-2021 http://www.HisiPHP.com
// +----------------------------------------------------------------------
// | HisiPHP承诺基础框架永久免费开源，您可用于学习和商用，但必须保留软件版权信息。
// +----------------------------------------------------------------------
// | Author: 橘子俊 <364666827@qq.com>，开发者QQ群：50304283
// +----------------------------------------------------------------------

namespace app\common\service;

use app\common\service\Base;

class SystemMenu extends Base
{

	/**
	 * 获取系统弹窗消息跳转地址信息
	 *
	 * @author King
	 * @date 2020年9月6日
	 *
	 * @param string $uri			uri
	 * @param string $menuParams	菜单表的param
	 * @param array $params			其它附加参数
	 */
	public function getSystemMsgUrlInfo($uri, $menuParams='', $params=[]) {
		$where = [
			['url', '=', $uri]
		];
		if ($menuParams!='') $where[] = ['param', '=', $menuParams];
		$menuInfo = db('system_menu')->where($where)->findOrEmpty();

		if (empty($menuInfo)) {
			return [
				'url' => '',
				'menu_id' => '',
				'title' => '',
				'iframe' => '',
			];
		}

		if ($params) {
			$paramsStr = http_build_query($params);
			if ($menuParams != '') {
				$menuParams .= '&'.$paramsStr;
			} else {
				$menuParams = $paramsStr;
			}
		}
		$result['url'] = url($uri, $menuParams, true, true);
		$result['menu_id'] = $menuInfo['id'];
		$result['title'] = $menuInfo['title'];

		return $result;
	}
}